package com.neuqsoft.ymtdemo;

import android.content.Context;
import android.support.multidex.MultiDex;

import com.uuzuche.lib_zxing.ZApplication;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
    //该ak渠道号仅供项目内部测试演示使用，接入渠道需替换为自己的ak，sk，渠道号



    public class App extends ZApplication {public static String channelNo = "";
        public static String accessKey = "";
        public static String environmentUrl="";
        public static String isAuthFace="";
        public static String x_client_name="qhdapp";
        private static App instance;
        /**
         * 签发成功后，回调回来的部分参数，测试使用
         */
        public static String signNO="";
        public static String aab301="";
        public static String aac002="";
        public static String aac003="";
        public static String token="";
        public static String paymoudle="3";
        public static String paymoney="300";

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(base);

    }

    @Override
        public void onCreate() {
            super.onCreate();
            instance=this;
            closeAndroidPDialog();
            //集成场景下在此初始化SDK

        }

        public static synchronized App getApp(){
            return instance;
        }

        /**
         * 去除安卓P私有API弹窗
         */
        private void closeAndroidPDialog(){
            try {
                Class aClass = Class.forName("android.content.pm.PackageParser$Package");
                Constructor declaredConstructor = aClass.getDeclaredConstructor(String.class);
                declaredConstructor.setAccessible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        try {
            Class cls = Class.forName("android.app.ActivityThread");
            Method declaredMethod = cls.getDeclaredMethod("currentActivityThread");
            declaredMethod.setAccessible(true);
            Object activityThread = declaredMethod.invoke(null);
            Field mHiddenApiWarningShown = cls.getDeclaredField("mHiddenApiWarningShown");
            mHiddenApiWarningShown.setAccessible(true);
            mHiddenApiWarningShown.setBoolean(activityThread, true);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
